
#pragma once

#include <pthread.h>
#include "condition.h"
#include "native-mutex.h"

namespace dulymoo {

class NativeCondition : public ICondition
{
public:
    explicit NativeCondition(NativeMutex &mutex);
    virtual ~NativeCondition();

private:
    NativeCondition(const NativeCondition&);  // unimplemented
    NativeCondition& operator= (const NativeCondition&);  // unimplemented

public:
    virtual bool Acquire();
    virtual bool TryAcquire();
    virtual void Release();

    virtual bool Wait();
    virtual bool TimedWait(const ABSTime &time);
    virtual bool TimedWait(unsigned int timeout);

    virtual bool Signal();
    virtual bool Broadcast();

private:
    NativeMutex &mutex_;
    pthread_cond_t cond_;
};

} // namespace dulymoo

